{extend name='public/window' /}

{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="form">
                <div class="layui-form-item">
                    <label class="layui-form-label">上级栏目：</label>
                    <div class="layui-input-block">
                        <select name="pid" lay-verify="required">
                            <option value="0">顶级栏目</option>
                            {$tree|make_option='','title_show','id'}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">分类名称：</label>
                    <div class="layui-input-block input-custom-width" style="">
                        <input type="text" name="name" value="" placeholder="请输入栏目名称" lay-verify="required"
                               lay-vertype="tips" lay-reqtext="请输入栏目名称" autocomplete="off" class="layui-input ">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">简要描述：</label>
                    <div class="layui-input-block input-custom-width" style="">
                        <textarea name="description" placeholder="" lay-verify="" autocomplete="off"
                                  class="layui-textarea"></textarea>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">排序：</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="number" name="sort" value="0" min="0" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux"></div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态：</label>
                    <div class="layui-input-inline input-custom-width">
                        <input type="radio" name="is_show" value="1" title="显示" lay-filter="" checked>
                        <input type="radio" name="is_show" value="0" title="不显示" lay-filter="">
                    </div>
                </div>


                {if isset($info.id)}
                <input type="hidden" name="id" value="{$info.id}">
                {/if}

                <div class="layui-form-item layui-layout-admin " style="width: 100%">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0px;text-align: center;">
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="add">提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            <span class="layui-btn layui-btn-danger" id="closed">关闭</span>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>


<script>
    layui.use(['element', 'form', 'jquery', 'lucky'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var lucky = layui.lucky;

        //表单赋值
        var info = {:isset($info)?json_encode($info):''} ;
        form.val("form", info);

        //提交
        form.on('submit(add)', function (data) {
            lucky.FormSubmit("{:url('upAndAdd')}", data.field, true);
            return false;
        });
        //关闭
        $('#closed').on('click',function () {
            window.parent.layer.closeAll();
        })
    })
</script>

{/block}

